<?php

class RadioButton extends InputField
{
	/**
	 * 
	 * Enter description here ...
	 * @var array
	 */
	protected $values;

	public function __construct($name, $values, $value = null)
	{
		parent::__construct('radio', $name, $value);
		$this->values = $values;
			
	}
	
	/**
	 * 
	 * @see HTMLElement::getHTML()
	 */
	public function getHTML()
	{
		$html = '';
		$i = 0;
		foreach($this->values as $label => $value)
		{
			$id = $this->name . '_' . $i;
		
			$html .= '<input type="radio" id="'.$id. '" name="'.$this->name.'" value="'.$value.'" ';
			if($this->value == $value)
			{
				$html .= 'checked="checked" ';
			}
			$html .= '/> ';		
			$html .= '<label class="radio" for="'.$id.'">'.$label.'</label> ';
			$i++;
		}
		return $html;
	}
}